package drds.server.sqlparser.sqlobject.expression;

import java.util.ArrayList;
import java.util.List;

import drds.server.sqlparser.visitor.Visitor;

/**
 * 
 * @author 曹正辉<330937205@qq.com>
 * 
 */
public class $List extends AbstractExpression {

	private final List<Expression> itemList = new ArrayList<Expression>();

	public void addItem(Expression item) {
		if (item != null) {
			item.setParent(this);
		}
		this.itemList.add(item);
	}

	public List<Expression> getItemList() {
		return itemList;
	}

	@Override
	protected void accept0(Visitor visitor) {
		if (visitor.visit(this)) {
			acceptChild(visitor, itemList);
		}
		visitor.endVisit(this);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((itemList == null) ? 0 : itemList.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null) {
			return false;
		}
		if (getClass() != o.getClass()) {
			return false;
		}
		$List other = ($List) o;
		if (itemList == null) {
			if (other.itemList != null) {
				return false;
			}
		} else if (!itemList.equals(other.itemList)) {
			return false;
		}
		return true;
	}

}
